import cn.hutool.extra.qrcode.QrCodeUtil;
import cn.hutool.extra.qrcode.QrConfig;
import cn.hutool.json.JSONUtil;
import com.google.zxing.common.BitMatrix;

import java.awt.*;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;

/**
 * @author zhangdi
 * @version 1.0
 * @date 2024.8.2
 */
public class CreateQRCode {
    public static void main(String[] args) {
        Map<String, Object> response = new HashMap<>();
        response.put("id", 1L);
        response.put("memberId", 22L);
        response.put("url", "/aaa/bbb/ccc");
        QrConfig config = new QrConfig()
                .setWidth(32)
                .setHeight(32)
                .setBackColor(Color.white)
                .setForeColor(Color.blue)
                .setCharset(StandardCharsets.UTF_8)
                .setMargin(1);

        QrCodeUtil.generate(JSONUtil.toJsonStr(response), config, new File("./qrimg/member111.png"));
//        BitMatrix encode = QrCodeUtil.encode(JSONUtil.toJsonStr(response), config);

    }
}
